package com.example.permissionservice.common.enums;

import lombok.Getter;

/**
 * （AI生成）
 */
@Getter
public enum RoleEnum {
    SUPER_ADMIN(1, "super_admin"),
    USER(2, "user"),
    ADMIN(3, "admin");

    private int roleId;
    private String roleCode;

    // 手动定义构造器
    RoleEnum(int roleId, String roleCode) {
        this.roleId = roleId;
        this.roleCode = roleCode;
    }

    public static RoleEnum getByRoleId(int roleId) {
        for (RoleEnum role : values()) {
            if (role.getRoleId() == roleId) {
                return role;
            }
        }
        return null;
    }

    public static RoleEnum getByRoleCode(String roleCode) {
        for (RoleEnum role : values()) {
            if (role.getRoleCode().equals(roleCode)) {
                return role;
            }
        }
        return null;
    }
}